package com.example.computer_exam_training_sys.mapper;

import com.example.computer_exam_training_sys.entity.UserFollow;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserFollowMapper {

    // 添加关注关系（插入）
    @Insert("INSERT INTO user_follows (user_id, followed_user_id) VALUES (#{userId}, #{followedUserId})")
    int insert(UserFollow userFollow);

    // 查询某个用户关注的所有人
    @Select("SELECT * FROM user_follows WHERE user_id = #{userId}")
    List<UserFollow> selectByUserId(@Param("userId") Integer userId);

    // 取消关注（联合唯一删除）
    @Delete("DELETE FROM user_follows WHERE user_id = #{userId} AND followed_user_id = #{followedUserId}")
    int delete(@Param("userId") Integer userId, @Param("followedUserId") Integer followedUserId);
    // 查询所有关注记录
    @Select("SELECT * FROM user_follows")
    List<UserFollow> selectAll();

}

